Conversation
Contributor
mailvijayasingh
commented
May 31, 2024
- Moved generation scripts to benchmarking module
- Added metrics file
|
Looks good overall, few comments. |
vipannalla
reviewed
Jun 5, 2024
| @@ -0,0 +1 @@ | |||
| {"metrics": {"compile_time": 34.46660280227661, "inference_time_1": 5.136486291885376, "inference_time_2": 5.136287450790405, "inference_time_3": 5.136406660079956, "inference_time_4": 5.136098861694336, "gcs_metrics": true, "save_config_to_gcs": false, "log_period": 100, "from_pt": false, "split_head_dim": true, "norm_num_groups": 32, "train_new_unet": false, "dcn_data_parallelism": -1, "dcn_fsdp_parallelism": 1, "dcn_tensor_parallelism": 1, "ici_data_parallelism": -1, "ici_fsdp_parallelism": 1, "ici_tensor_parallelism": 1, "resolution": 1024, "center_crop": false, "random_flip": false, "tokenize_captions_num_proc": 4, "transform_images_num_proc": 4, "reuse_example_batch": false, "enable_data_shuffling": true, "cache_latents_text_encoder_outputs": true, "learning_rate": 4e-07, "scale_lr": false, "max_train_samples": -1, "max_train_steps": 200, "num_train_epochs": 1, "seed": 0, "per_device_batch_size": 2, "warmup_steps_fraction": 0.0, "learning_rate_schedule_steps": 200, "adam_b1": 0.9, "adam_b2": 0.999, "adam_eps": 1e-08, "adam_weight_decay": 0.01, "enable_profiler": true, "skip_first_n_steps_for_profiler": 1, "profiler_steps": 5, "guidance_scale": 9, "guidance_rescale": 0.0, "num_inference_steps": 20, "lightning_from_pt": true, "enable_mllog": false, "use_controlnet": false, "controlnet_from_pt": true, "controlnet_conditioning_scale": 0.5}, "dimensions": {"date": "20240531-215048", "run_name": "my_run", "metrics_file": "", "model_name": "SDXL-1.0", "pretrained_model_name_or_path": "stabilityai/stable-diffusion-xl-base-1.0", "revision": "refs/pr/95", "dtype": "bfloat16", "attention": "dot_product", "flash_block_sizes": "{}", "diffusion_scheduler_config": "{'_class_name': '', 'prediction_type': '', 'rescale_zero_terminal_snr': False, 'timestep_spacing': ''}", "base_output_directory": "", "mesh_axes": "['data', 'fsdp', 'tensor']", "logical_axis_rules": "(('batch', 'data'), ('activation_batch', 'data'), ('activation_length', 'fsdp'), ('out_channels', 'fsdp'), ('conv_out', 'fsdp'), ('length', 'fsdp'))", "data_sharding": "(('data', 'fsdp', 'tensor'),)", "dataset_name": "diffusers/pokemon-gpt4-captions", "dataset_save_location": "/tmp/pokemon-gpt4-captions_xl", "train_data_dir": "", "dataset_config_name": "", "cache_dir": "", "image_column": "image", "caption_column": "text", "output_dir": "sdxl-model-finetuned", "prompt": "A magical castle in the middle of a forest, artistic drawing", "negative_prompt": "purple, red", "lightning_repo": "", "lightning_ckpt": "", "controlnet_model_name_or_path": "diffusers/controlnet-canny-sdxl-1.0", "controlnet_image": "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Google_%22G%22_logo.svg/1024px-Google_%22G%22_logo.svg.png", "tensorboard_dir": "sdxl-model-finetuned/my_run/tensorboard/", "checkpoint_dir": "sdxl-model-finetuned/my_run/checkpoints/", "metrics_dir": "sdxl-model-finetuned/my_run/metrics/"}} No newline at end of file | |||
There was a problem hiding this comment.
Is this an example file? Do we need this commited?
Comment on lines
+93
to
+101
| output = pipe( | ||
| prompt_ids=prompt_ids, | ||
| image=processed_image, | ||
| params=p_params, | ||
| prng_seed=rng, | ||
| num_inference_steps=config.num_inference_steps, | ||
| neg_prompt_ids=negative_prompt_ids, | ||
| controlnet_conditioning_scale=controlnet_conditioning_scale, | ||
| jit=True, |
Comment on lines
+103
to
+104
| inference_time = time.time() - s | ||
| metrics_dict[f"inference_time_{iter}"] = inference_time |
There was a problem hiding this comment.
These two are the only lines different between if and else block. Can you just use if..else around these lines?
if iter == 0:
metrics_dict["compile_time"] = time.time() - s
else:
metrics_dict[f"inference_time_{iter}"] = time.time() - s
Comment on lines
+259
to
+293
| metrics_dict = {} | ||
| for iter in range(NUM_ITER): | ||
| if iter == 0: | ||
| s = time.time() | ||
| p_run_inference(unet_state, vae_state, params).block_until_ready() | ||
| metrics_dict["compile_time"] = time.time() - s | ||
| else: | ||
| s = time.time() | ||
| images = p_run_inference(unet_state, vae_state, params).block_until_ready() | ||
| images.block_until_ready() | ||
| inference_time = time.time() - s | ||
| metrics_dict[f"inference_time_{iter}"] = inference_time | ||
|
|
||
| dimensions_dict = {} | ||
| current_dt = datetime.datetime.now().strftime("%Y%m%d-%H%M%S") | ||
| dimensions_dict["date"] = current_dt | ||
|
|
||
| for dim in config.get_keys(): | ||
| val = config.get(dim) | ||
| if isinstance(val, str): | ||
| dimensions_dict[str(dim)] = str(config.get(dim)) | ||
| elif isinstance(val, int) or isinstance(val, float): | ||
| metrics_dict[dim] = val | ||
| else: | ||
| dimensions_dict[str(dim)] = str(val) | ||
|
|
||
| final_dict = {} | ||
| final_dict["metrics"] = metrics_dict | ||
| final_dict["dimensions"] = dimensions_dict | ||
|
|
||
| print("final_dict is ", final_dict) | ||
|
|
||
| with open("metrics.json", 'w') as f: | ||
| f.write(json.dumps(final_dict)) | ||
|
|
There was a problem hiding this comment.
This looks same as that in sd2/generate.py, can you move common code into utils.py and re-use?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.